<template>
  <view class="wrap">
    <u-notice-bar mode="horizontal" :list="list" type="success"></u-notice-bar>
    <view class="contact">
      <view class="btn_box " @click="nPost()">
        <view class="text u-font-40">
          招新发布
        </view>
      </view>
      <!-- <view class="btn_box"  @click="go('/pages/actman/actman','组织管理')">
				<view class="text u-font-40" >
					活动发布
				</view>
			</view> -->
    </view>
    <!-- //历史招新人数图表与活动报名人数图表 -->
    <view class="forms">
      历史招新
      <view class="form">
        <view v-for="(item,index) in lists" :key="item.id" @click="get(item.id)">
          第{{ Number(index)+1 }}次招新
          <u-line-progress :striped="true" :percent="item.number" :striped-active="true"></u-line-progress>
        </view>
        <!-- <view class="charts-box">
          <qiun-data-charts type="column" :chartData="chartData" :inScrollView="true" :disableScroll="true" background="none" :tooltipShow="false" :ontouch="true" scrollLeft @getIndex="get" />
        </view> -->
      </view>
    </view>
  </view>
</template>
//组织管理页。
<script>
  export default {
    data() {
      return {
        list: [
          '欢迎来到super招新的组织管理平台'
        ],
        oId: '', //组织id——存于缓存，用于查询相关信息
        orgs: [{
          id: '', //招新id用于获取招新的所有学生基本
          number: '' //招新报名数量
        }],
        act: [{
          id: '', //招新id用于获取活动的所有学生基本
          number: '' //活动报名数量
        }],
        lists: [],
        class: '',
      }
    },
    onLoad(option) {
      this.class_one = option.class_one
      console.log(this.class_one)
      // console.log(this.chartData.series[0].data)
      // let test = [{
      //   id: '01',
      //   number: 1
      // }, {
      //   id: '02',
      //   number: 2
      // }, {
      //   id: '03',
      //   number: 3
      // }]
      // let chartData = this.chartData
      // let series = chartData.series[0].data
      // for (let i = 0; i < test.length; i++) {
      //   console.log(i)
      //   console.log(test[i])
      //   // 招新时间
      //   chartData.categories[i] = test[i].id
      //   // 参与人数
      //   series[i] = test[i].number
      //   series[test.length + i] = (test[i].number + 1)
      // }
      // series[test.length] = 0
      // console.log(test[test.length - 1].number)
    },
    onReady() {
      let that = this
      console.log(this.getToken)
      this.$request({
        url: '/joinstus',
        header: {
          'Authorization': "Bearer " + this.getToken
        }
      }).then(res => {
        if (res.code == 200) {
          // let data = that.lists = res.data
          for (let i = 0;i<res.data.length;i++) {
            that.$set(that.lists,i,res.data[i])
          }
          console.log(that.lists)
          // this.refresh
          // let chartData = that.chartData
          // let series = that.chartData.series[0].data
          // for (let i = 0; i < data.length; i++) {
          //   console.log(i)
          //   // 招新时间
          //   that.$set(chartData.categories,i,data[i].id.toString())
          //   // that.chartData.categories[i] = data[i].id.toString()
          //   // console.log(chartData.categories[i])
          //   console.log(data[i])
          //   // 参与人数
          //   that.$set(series,i,data[i].number)
          //   that.$set(series,data.length+i,data[i].number+1)
          //   // series[i] = data[i].number
          //   // series[data.length + i] = data[i].number + 1
          // }
          // series[data.length] = 0
          // return that.chartData.series[0].data[that.lists.length] = 0
        }
      }).catch(err => {
        console.log(err)
      })
    },
    computed: {
      getToken() {
        return uni.getStorageSync('org_token')
      },
    },
    methods: {
      num(e) {
        console.log(e)
        return Number(e)
      },
      go(url, title) {
        console.log(url)
        uni.navigateTo({
          url: url + '?title=' + title
        })
      },
      get(id) {
        // console.log(e.currentIndex.index)
        // let index = e.currentIndex.index
        // let id = this.lists[index].id
        uni.navigateTo({
          url: '/pages/orgman/orgman' + '?id=' + id + '&class_one=' + this.class_one
        })
      },
      nPost() {
        let url = '/sendorg'
        if (this.class_one == '社团') {
          url = '/sendst'
        }
        // uni.navigateTo({
        //   url: '/pages/orgnizes/orgnizes'
        // })
        uni.navigateTo({
          url: '/pages' + url + url
        })
      }
    }
  }
</script>

<style>
  .contact {
    text-align: center;
    display: flex;
    flex-direction: row;
  }

  .btn_box {
    padding: 20rpx;
    border-radius: 10rpx;
    width: 250rpx;
    height: 150rpx;
    margin: 60rpx;
    -webkit-box-shadow: 0px 3px 3px #c8c8c8;
    -moz-box-shadow: 0px 3px 3px #c8c8c8;
    box-shadow: 0px 3px 3px #c8c8c8;
    background-image: linear-gradient(to bottom right, #f5af19, #f12711);
    color: white;
  }

  .text {
    line-height: 115rpx;
  }

  .forms {
    display: flex;
    align-items: center;
    /* justify-content: center; */
    flex-direction: column;
    font-size: 35rpx;
  }

  .form {
    padding: 0 10rpx 10rpx;
    border-radius: 10rpx;
    width: 98vw;
    -webkit-box-shadow: 2px 3px 5px #c8c8c8;
    -moz-box-shadow: 2px 3px 5px #c8c8c8;
    box-shadow: 2px 3px 5px #c8c8c8;
  }
</style>
<style>
  .charts-box {
    width: 97vw;
    height: 400rpx;
  }
</style>
